<template>
	<view class="wrap">
		<u-navbar title="添加最近事项" :is-back="isBack" back-text="返回" :background="background"></u-navbar>
		<u-form :model="model" ref="uForm" :errorType="errorType">

			<u-form-item :label-position="labelPosition" label="事项" left-icon="star-fill">
				<u-input type="textarea" :border="border" :height="height" :auto-height="autoHeight" placeholder="请填写事项" v-model="form.content" />
			</u-form-item>

		</u-form>

		<u-toast ref="uToast" />

		<u-button :plain="true" type="primary" shape="circle" @click="submit">提交</u-button>
		<u-tabbar :list="vuex_tabbar" :mid-button="true"></u-tabbar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					content: undefined
				},
				background: {
					backgroundImage: 'linear-gradient(19deg, #21D4FD 0%, #B721FF 100%)'
				},
				isBack: true,
				duration: 100,
				model: {
					intro: '',
				},
				autoHeight: true,
				height: 400,
				border: true,
				labelPosition: 'top',
				errorType: ['message'],
			};
		},
		onLoad() {

		},
		computed: {

		},
		methods: {
			submit() {
				console.info(this.form)
				this.$u.post('/recently/add', this.form).then(res => {})
				this.$refs.uToast.show({
					title: '提交成功',
					type: 'success',
					duration: 500,
					callback: () => {
						console.info("callback")
						this.form = ''
						uni.switchTab({
							url: '/pages/index/index',
						})
					},
				})
			},
		}
	};
</script>

<style scoped lang="scss">
	.wrap {
		padding: 30rpx;
	}

	.close-btn {
		height: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.agreement {
		display: flex;
		align-items: center;
		margin: 40rpx 0;

		.agreement-text {
			padding-left: 8rpx;
			color: $u-tips-color;
		}
	}
</style>
